home *** CD-ROM | disk | FTP | other *** search
/ The Guided Tour of Multimedia (Second Edition) / The Guided Tour of Multimedia (Second Edition).iso / trials / qtw111 / samples / eachmov.bas < prev    next >
BASIC Source File  |  1993-03-15  |  3KB  |  113 lines

  1. ' Require that all variables be declared
  2. Option Explicit
  3.  
  4. ' Style flag used by the Show Method
  5. Global Const MODELESS = 0
  6. Global Const MODAL = 1
  7.  
  8. ' Global data
  9. Global BorderWidth As Integer   ' Width of frmEachMov border
  10. Global BorderHeight As Integer  ' Height of frmEachMov border
  11.  
  12. Global MovieCount As Integer    ' Count of movies in MoviePath
  13. Global MovieNum As Integer      ' Current movie number
  14.  
  15. Global MoviePath As String      ' Path containing the movies
  16. Global MovieName() As String    ' Movie name array
  17.  
  18. Sub Main ()
  19. '   Calculate the frame border width and height
  20.     BorderWidth = frmEachMov.Width - frmEachMov.ScaleWidth
  21.     BorderHeight = frmEachMov.Height - frmEachMov.ScaleHeight
  22.  
  23. '   Load the directory form
  24.     frmEachMovDir.Show MODAL
  25.  
  26. '   Load the movie form; start playing the movies
  27.     Load frmEachMov
  28.     StartTheMovies
  29. End Sub
  30.  
  31. Sub PlayMovie ()
  32. '   Frame coordinate data
  33.     Dim formLeft As Long, formTop As Long
  34.     Dim formWidth As Long, formHeight As Long
  35.  
  36. '   If the movie number exceeds the array limit, we're done
  37.     If MovieNum >= MovieCount Then End
  38.  
  39. '   Hide the movie form so we can adjust its size and location
  40.     frmEachMov.Hide
  41.  
  42. '   Set the movie name from the array
  43.     frmEachMov!QTMovie1.MovieName = MoviePath + "\" + MovieName(MovieNum)
  44.  
  45. '   Suppress the movie controller
  46.     frmEachMov!QTMovie1.Visible = False
  47.  
  48. '   Calculate the frame dimensions to exactly fit the movie
  49.     formWidth = frmEachMov!QTMovie1.Width + BorderWidth
  50.     If formWidth > Screen.Width Then formWidth = Screen.Width
  51.     formHeight = frmEachMov!QTMovie1.Height + BorderHeight
  52.     If formHeight > Screen.Height Then formHeight = Screen.Height
  53.  
  54. '   Calculate the frame position at screen center
  55.     formLeft = (Screen.Width - formWidth) / 2
  56.     If formLeft < 0 Then formLeft = 0
  57.  
  58.     formTop = (Screen.Height - formHeight) / 2
  59.     If formTop < 0 Then formTop = 0
  60.  
  61. '   Move the frame
  62.     frmEachMov.Move formLeft, formTop, formWidth, formHeight
  63.  
  64. '   Show the movie frame
  65.     frmEachMov.Show MODELESS
  66. End Sub
  67.  
  68. Sub StartTheMovies ()
  69.     Dim FileName As String      ' Current movie file name
  70.     
  71. '   Initialize the movie count data
  72.     MovieCount = 0
  73.     MovieNum = 0
  74.  
  75. '   Find the first movie in the movie path
  76.     FileName = Dir$(MoviePath + "\*.mov")
  77.  
  78. '   Loop through the path to get a count of the movies
  79.     While (FileName <> "")
  80.         MovieCount = MovieCount + 1
  81.         FileName = Dir$
  82.     Wend
  83.  
  84. '   Let the user know if there's no movies in this directory,
  85. '   then end the program
  86.  
  87.     If MovieCount = 0 Then
  88.         MsgBox "There are no movies in directory " + MoviePath, 0, "EachMov"
  89.         End
  90.     End If
  91.  
  92. '   Dimension the MovieName array depending on the number
  93. '   of movies in the path
  94.     ReDim MovieName(MovieCount) As String
  95.  
  96. '   One more time, get the first movie in the path
  97.     FileName = Dir$(MoviePath + "\*.mov")
  98.  
  99. '   Load the MovieName array with all the movie names
  100.     While (FileName <> "")
  101.         MovieName(MovieNum) = FileName
  102.         MovieNum = MovieNum + 1
  103.         FileName = Dir$
  104.     Wend
  105.  
  106. '   Go to the first movie and play it
  107.     MovieNum = 0
  108.  
  109. '   Set the timer interval to start the next movie
  110.     frmEachMov!tmrMovie.Interval = 1
  111. End Sub
  112.  
  113.